package com.backedserver.aop;

import com.common.excel.ExcelListener;
import com.common.excel.ExcelValueCheckResp;
import com.common.vo.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * 主要用来清除 ExcelListener.clean 中的错误信息 防止下次导入还是存在上次错误信息
 *
 * @author johnny
 * @create 2021-05-16 7:25 下午
 **/
@Aspect
@Component
@Slf4j
public class ImportAspectJ {

    @AfterReturning(returning = "v", pointcut = "execution(* com.backedserver.controller..import*(..))")
    public void cleanImportErrorInfo(Object v) {
        ResultVo resultVo = (ResultVo) v;
        ExcelValueCheckResp data = (ExcelValueCheckResp) resultVo.getData();
        log.info("【导入返回 ExcelValueCheckResp : {}】", data);
        ExcelListener.clean();
    }
}